
#ifndef SPECTRUMWIDGET_H
#define SPECTRUMWIDGET_H

#include <QWidget>
#include <QVector>
#include <QTimer>

class SpectrumWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SpectrumWidget(QWidget *parent = nullptr);

    void updateSpectrum(const QVector<float> &spectrum);
    void setNumBands(int numBands);

protected:
    void paintEvent(QPaintEvent *event) override;

private:
    QVector<float> m_spectrum;
    QVector<float> m_targetSpectrum;
    int m_numBands;
    QTimer *m_animationTimer;

    QColor getGradientColor(float value) const;
    void smoothTransition();

private slots:
    void onAnimationTimer();
};

#endif // SPECTRUMWIDGET_H